<script setup lang="ts">
import * as echarts from "echarts";
import { onMounted, ref } from "vue";

let charts = ref();

onMounted(() => {
  initCharts();
});

const initCharts = () => {
  let myChart = echarts.init(charts.value);
  myChart.setOption({
    title: {
      text: "热门景区排名",
      left: "center",
      show: false,
      textStyle: {
        color: "#fff",
        fontSize: 16,
      },
    },
    xAxis: {},
    yAxis: {
      type: "category", // 谁是类目轴
      data: ["景区1", "景区2", "景区3", "景区4", "景区5", "景区6"],
    },
    series: [
      {
        type: "bar",
        // 由大到小
        data: [200, 300, 400, 400, 700, 1000],

        // 柱子标签
        label: {
          show: true, // 显示标签
          position: "insideRight", // 标签位置
          color: "#fff", // 标签颜色
        },
      },
      //   series中是可以放多个图表的
      {
        type: "line",
        data: [200, 300, 400, 400, 700, 1000],
      },
    ],
    // 提示相关配置
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },
    grid: {
      left: "3%",
      right: "4%",
      bottom: "3%",
      top: "20%",
      containLabel: true,
    },
  });
};

defineOptions({
  name: "Rank",
});
</script>

<template>
  <div class="box6">
    <div class="title">
      <p>热门景区排名</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<style scoped lang="scss">
.box6 {
  width: 100%;
  height: 100%;
  background: url("../../images/dataScreen-main-cb.png") no-repeat;
  background-size: 100% 100%;
  .title {
    p {
      font-size: 16px;
      color: #fff;
      margin-top: 10px;
    }
  }

  .charts {
    height: calc(100% - 40px);
  }
}
</style>
